package Java2Test.threadpool.threadpool1;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadPoolDemo {

    /*
        public static ExecutorService newCachedThreadPool()     创建一个没有上限的线程池
        public static ExecutorService newFixedThreadPool（int nThreads）创建有上限的线程池
     */

    public static void main(String[] args) throws InterruptedException {

        ExecutorService pool1 = Executors.newFixedThreadPool(3);
        MyRunnable mr = new MyRunnable();
        pool1.submit(mr);
        pool1.submit(mr);
        pool1.submit(mr);
        pool1.submit(mr);
        pool1.submit(mr);
        pool1.submit(mr);

//        pool1.shutdown();
    }
}
